package com.kangye.learnteacher.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.kangye.learnteacher.entity.Classes;
import com.kangye.learnteacher.entity.User;
import com.kangye.learnteacher.mapper.ClassesMapper;
import com.kangye.learnteacher.service.ClassesService;
import com.kangye.learnteacher.util.ViewJsonObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class ClassesServiceImpl implements ClassesService {
    @Autowired
    private ClassesMapper classesMapper;
@Autowired
private ViewJsonObject viewJsonObject;

    @Override
    public ViewJsonObject<Classes> getClasses(Integer page, Integer limit,String classesName) {
        PageHelper.startPage(page,limit);
        List<Classes> list =  classesMapper.getClasses(page, limit,classesName);
        PageInfo<Classes> pageInfo =  new PageInfo<>(list);
        viewJsonObject.setData(pageInfo.getList());
        viewJsonObject.setCount(pageInfo.getTotal());
        viewJsonObject.setCode(0);
        viewJsonObject.setMsg("");
        return viewJsonObject;
    }
//修改
    @Override
    public boolean upClasses(Classes classes) {
        return this.classesMapper.upClasses(classes)>0;
    }

}
